import 'package:flutter/material.dart';

class Movie extends StatelessWidget {

  final String title;
  final String posterSmall;
  final String sourceName;
  final String duration;
  final String fmplaycnt;
  final String fmlike;

  Movie(
      {this.duration, this.title, this.fmlike, this.fmplaycnt, this.posterSmall, this.sourceName});


  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        border: Border.all(width: 1, color: Colors.black12),
        borderRadius: BorderRadius.circular(10),
      ),
      margin: EdgeInsets.all(5),
      child: Column(
        mainAxisSize: MainAxisSize.max,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Container(
              height: 105,
              decoration: BoxDecoration(
                borderRadius: new BorderRadius.vertical(
                    top: Radius.circular(10)),
                image: DecorationImage(
                  image: NetworkImage(posterSmall),
                  fit: BoxFit.cover,
                ),
              ),
              child: Align(
                alignment: Alignment.bottomCenter,
                child: Container(
                  height: 20,
                  decoration: BoxDecoration(
                      gradient: LinearGradient(
                          begin: Alignment.topCenter,
                          end: Alignment.bottomCenter,
                          colors: [
                            Colors.black12,
                            Colors.black26,
                            Colors.black38,
                            Colors.black
                          ])
                  ),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceAround,
                    children: <Widget>[
                      BottomTitle(icon: Icons.remove_red_eye, title: fmplaycnt),
                      BottomTitle(icon: Icons.favorite_border, title: fmlike),
                      BottomTitle(icon: Icons.access_time, title: duration)
                    ],
                  ),
                ),
              )
          ),
          Padding(
            padding: EdgeInsets.all(5),
            child: Container(
              height: 30,
              child: Text(title,
                textAlign: TextAlign.start,
                maxLines: 2,
                overflow: TextOverflow.ellipsis,
                style: TextStyle(
                    fontSize: 12
                ),
              ),
            ),
          ),
          Padding(
            padding: EdgeInsets.only(left: 6, right: 4),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Flexible(
                  child: Text(sourceName,
                    textAlign: TextAlign.start,
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                    style: TextStyle(
                        fontSize: 13,
                        color: Colors.black38
                    ),
                  ),

                ),
                Icon(Icons.more_vert, color: Colors.black38, size: 14,)
              ],
            ),
          )

        ],
      ),
    );
  }
}

class BottomTitle extends StatelessWidget {
  String title;
  IconData icon;

  BottomTitle({Key key, this.icon, this.title}) : super(key: key);


  @override
  Widget build(BuildContext context) {
    return Container(
      child: Row(
        children: <Widget>[
          Icon(icon, size: 14, color: Colors.white),
          SizedBox(
            width: 1,
          ),
          Text(title, style: TextStyle(color: Colors.white, fontSize: 10),)
        ],
      ),
    );
  }
}

